package com.dz.config;

import com.dz.interception.GuideLoginInterceptor;
import com.dz.interception.ManagerLoginInterceptor;
import com.dz.interception.VisitorLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WEBConfig implements WebMvcConfigurer {
    // 配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry  registry){
        // 管理员拦截器
        registry.addInterceptor(new ManagerLoginInterceptor())
                // 拦截所有
                .addPathPatterns("/m/**")
                // 不拦截
                .excludePathPatterns("/login/**","/register");

        // 地陪拦截器
        registry.addInterceptor(new GuideLoginInterceptor())
                // 拦截所有
                .addPathPatterns("/g/**")
                // 不拦截
                .excludePathPatterns("/login/**","/register");

        // 游客拦截器
        registry.addInterceptor(new VisitorLoginInterceptor())
                // 拦截所有
                .addPathPatterns("/v/**")
                // 不拦截
                .excludePathPatterns("/login/**","/register");

    }
}
